version: '3'

services:
  app:
    build:
      dockerfile: ./Dockerfile
      context: .
    environment:
      DATABASE_URL: postgresql://user:password@pg:5432/blog
    ports:
      - 8080:5050
    depends_on:
      - database

  database:
    image: postgres:12.7-alpine
    environment:
      POSTGRES_DB: blog
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - 5432:5432

volumes:
  pgdata:
